home *** CD-ROM | disk | FTP | other *** search
- -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C)
- -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
- --
- class TEST_CLONE
-
- inherit
- ANY
- redefine
- copy, is_equal
- end;
-
- creation {ANY}
- make
-
- feature {ANY}
-
- s1, s2: STRING;
- a1, a2: ANIMAL;
-
- ai1, ai2: ARRAY[INTEGER];
-
- p1, p2: POINT;
- t1, t2: TRIANGLE;
-
- make is
- local
- test_clone: like Current;
- do
- s1 := "foo";
- s2 := clone(s1);
- is_true(s1 /= s2);
- is_true(equal(s1,s2));
- is_true(s2.capacity >= s2.count);
- s1.put('b',2);
- is_true(not equal(s1,s2));
-
- !CAT!a1;
- a2 := clone(a1);
- is_true(a1 /= a2);
- is_true(equal(a1,a2));
-
- ai1 := <<1,2,3>>;
- ai2 := clone(ai1);
- is_true(equal(ai1,ai2));
- is_true(ai1 /= ai2);
-
- !!p1.make(1,2);
- p2 := clone(p1);
- is_true(p1 /= p2);
- is_true(p1.x = p2.x);
- is_true(p1.y = p2.y);
- is_true(p1.same_type(p2));
-
- !!t1.make(p1,p2,p2);
- t2 := clone(t1);
- is_true(t1 /= t2);
- is_true(t1.same_type(t2));
- is_true(t1.p1 = t2.p1);
- is_true(t1.p2 = t2.p2);
- is_true(t1.p3 = t2.p3);
- is_true(t2.p2 = t2.p3);
-
- test_clone := clone(Current);
- is_true(test_clone.same_type(Current));
- is_true(test_clone.s1 = Void);
- is_true(test_clone.s2 = Void);
- is_true(test_clone.ai1 = Void);
- is_true(test_clone.t1 = Void);
- is_true(test_clone.t2 = Void);
-
- -- ??? is_true(3 = clone(3));
- end;
-
- copy(other: like Current) is
- do
- end;
-
- is_equal(other: like Current): BOOLEAN is
- do
- Result := true;
- end;
-
- is_true(b: BOOLEAN) is
- do
- cpt := cpt + 1;
- if not b then
- std_output.put_string("TEST_CLONE: ERROR Test # ");
- std_output.put_integer(cpt);
- std_output.put_string("%N");
- else
- -- std_output.put_string("Yes %N");
- end;
- end;
-
- cpt: INTEGER;
-
- end -- TEST_CLONE
-